package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ForecastnameMapper;
import com.ruoyi.system.domain.Forecastname;
import com.ruoyi.system.service.IForecastnameService;
import com.ruoyi.common.core.text.Convert;

import javax.annotation.Resource;

/**
 * 预报名管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-11-08
 */
@Service
public class ForecastnameServiceImpl implements IForecastnameService 
{
    @Resource
    private ForecastnameMapper forecastnameMapper;

    /**
     * 查询预报名管理
     * 
     * @param stuId 预报名管理主键
     * @return 预报名管理
     */
    @Override
    public Forecastname selectForecastnameByStuId(String stuId)
    {
        return forecastnameMapper.selectForecastnameByStuId(stuId);
    }

    /**
     * 查询预报名管理列表
     * 
     * @param forecastname 预报名管理
     * @return 预报名管理
     */
    @Override
    public List<Forecastname> selectForecastnameList(Forecastname forecastname)
    {
        return forecastnameMapper.selectForecastnameList(forecastname);
    }

    /**
     * 新增预报名管理
     * 
     * @param forecastname 预报名管理
     * @return 结果
     */

    public int insertForecastname(Forecastname forecastname)
    {
        if (forecastname.getStuId() == null||"".equals(forecastname.getStuId())){
            String uuid = UUID.randomUUID().toString();
            String s="PHID"+DateUtils.dateTime()+uuid.substring(uuid.length()-5,uuid.length()-1);
            forecastname.setStuId(s);
        }
        return forecastnameMapper.insertForecastname(forecastname);
    }

    /**
     * 修改预报名管理
     * 
     * @param forecastname 预报名管理
     * @return 结果
     */
    @Override
    public int updateForecastname(Forecastname forecastname)
    {
        return forecastnameMapper.updateForecastname(forecastname);
    }

    /**
     * 批量删除预报名管理
     * 
     * @param stuIds 需要删除的预报名管理主键
     * @return 结果
     */
    @Override
    public int deleteForecastnameByStuIds(String stuIds)
    {
        return forecastnameMapper.deleteForecastnameByStuIds(Convert.toStrArray(stuIds));
    }

    /**
     * 删除预报名管理信息
     * 
     * @param stuId 预报名管理主键
     * @return 结果
     */
    @Override
    public int deleteForecastnameByStuId(String stuId)
    {
        return forecastnameMapper.deleteForecastnameByStuId(stuId);
    }

    @Override
    public int updateStace1(String id) {
        return forecastnameMapper.updateStace1(id);
    }

    @Override
    public int updateStace2(String id) {
        return forecastnameMapper.updateStace2(id);
    }


}
